$.ajaxSetup({
	cache: true,
	complete: function(XMLHttpRequest, textStatus) {
		var status = XMLHttpRequest.status;
		if (status == 401) {
			alert('您还未登录，或您的登录超时，或您的账号在其他地方已登录！');
			// location.reload(true);
		}
		if (status == 403)
			alert('系统异常，请联系在线客服！');
	}
});

var arrzxhz = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 63, 69, 73, 75, 75, 73, 69, 63, 55, 45, 36, 28, 21, 15, 10, 6, 3, 1];
var arrzuxhz = [1, 2, 2, 4, 5, 6, 8, 10, 11, 13, 14, 14, 15, 15, 14, 14, 13, 11, 10, 8, 6, 5, 4, 2, 2, 1];
var arrzxhzex = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1];
var arrkuadusx = [10, 54, 96, 126, 144, 150, 144, 126, 96, 54];
var arrkuaduex = [10, 18, 16, 14, 12, 10, 8, 6, 4, 2];
way.options.persistent = false;
way.options.timeoutInput = 50;
way.options.timeoutDOM = 500;
var Env = {
	price: 1,
	repoint: 0.05,
	// maxRepoint:0.05,
	// minMode:1850,
	lottery: 'cqssc',
	defaultCalculate: function(group) {
		if (Env.startMoney.toString().indexOf("/") < 1) {
			// way.set('Lottery.prize', (Env.startMoney * way.get("http://www.yugj881.com/resources/main/Lottery.mode") / Env.minMode * way.get("http://www.yugj881.com/resources/main/Lottery.yjf")).toFixed(4));
			var fix = 0;
			if (Env.maxRuleMode == 1700) {
				fix = Env.startMoney;
			} else {
				fix = (Env.endMoney - Env.startMoney) / (Env.maxRuleMode - 1700) * (way.get("http://www.yugj881.com/resources/main/Lottery.mode") - 1700) + Env.startMoney;
			}
			way.set('Lottery.prize', (fix * way.get("http://www.yugj881.com/resources/main/Lottery.yjf")*Env.price).toFixed(4));
		} else {
			var prizes = Env.startMoney.split("/");
			var endMoney = Env.otherEndMoney.split(",");
			var prize = "";
			for (var i = 0; i < prizes.length; i++) {
				if (!prize) {
					// prize = (parseFloat(prizes[i]) * way.get("http://www.yugj881.com/resources/main/Lottery.mode") / Env.minMode * way.get("http://www.yugj881.com/resources/main/Lottery.yjf")).toFixed(4);
					var fix = (endMoney[0].split(" ")[1] - parseFloat(prizes[i])) / (Env.maxRuleMode - 1700) * (way.get("http://www.yugj881.com/resources/main/Lottery.mode") - 1700) + parseFloat(prizes[i]);
					prize = (fix * way.get("http://www.yugj881.com/resources/main/Lottery.yjf")*Env.price).toFixed(4);
				} else {
					if(group=='lhwq'|| group=='lhwb'|| group=='lhws'|| group=='lhwg'|| group=='lhwg'|| group=='lhqb'|| group=='lhqs'|| group=='lhqg'|| group=='lhbs'|| group=='lhbg'|| group=='lhsg'||
						group=='pl3zuxhh'||group=='rx3zxhh'||group=='sxhhzxq'||group=='sxhhzxz'||group=='sxhhzxh'||group=='zuxhzqs'||group=='zuxhzzs'||group=='zuxhzhs'){
						prize = prize + "/" + (((endMoney[i].split(" ")[1] - parseFloat(prizes[i])) / (Env.maxRuleMode - 1700) * (way.get("http://www.yugj881.com/resources/main/Lottery.mode") - 1700) + parseFloat(prizes[i])) * way.get("http://www.yugj881.com/resources/main/Lottery.yjf")*Env.price).toFixed(4);
					}
				}
			}
			way.set('Lottery.prize', prize);
		}
		// if (Env.startMoney.toString().indexOf("/") < 1) {
		// 	way.set('Lottery.prize', (Env.startMoney * way.get("http://www.yugj881.com/resources/main/Lottery.mode") / Env.minMode * way.get("http://www.yugj881.com/resources/main/Lottery.yjf")).toFixed(4));
		// } else {
		// 	var prizes = Env.startMoney.split("/");
		// 	var prize = "";
		// 	for (var i = 0; i < prizes.length; i++) {
		// 		if (!prize) {
		// 			prize = (parseFloat(prizes[i]) * way.get("http://www.yugj881.com/resources/main/Lottery.mode") / Env.minMode * way.get("http://www.yugj881.com/resources/main/Lottery.yjf")).toFixed(4);
		// 		} else {
		// 			prize = prize + "/" + (parseFloat(prizes[i]) * way.get("http://www.yugj881.com/resources/main/Lottery.mode") / Env.minMode * way.get("http://www.yugj881.com/resources/main/Lottery.yjf")).toFixed(4);
		// 		}
		// 	}
		// 	way.set('Lottery.prize', prize);
		// }
	}
};
var rule = {};
var Lottery_Rule = function() {

	var curdiv;
	var curRule;
	var shortName;
	var isFirst = false;
	var equalizer_status = false;

	var verificateOrder = function() {

		//		var v_maxMultiplePerOrder = parseInt(curRule.maxMultiplePerOrder);

		var v_maxPrize = parseFloat(Env.maxPrize);

		var v_maxRecord = parseInt(Env.maxRecord);

		var real_multiplePerOrder = parseInt(way.get("Lottery.times"));

		var real_record = parseInt(way.get("Lottery.itemcount"));

		var c_prize = way.get("Lottery.s_prize") ? way
			.get("Lottery.s_prize") : way.get("Lottery.prize");

		var c_record = curRule.obtainMaxBetNumberPerOrder ? curRule
			.obtainMaxBetNumberPerOrder(real_record) : 1;
		var real_total_prize = (real_record * real_multiplePerOrder *
			way.get("http://www.yugj881.com/resources/main/Lottery.yjf")).toFixed(4);

		var vSelMode = way.get("http://www.yugj881.com/resources/main/Lottery.mode");
		vSelMode = Number(vSelMode);
		var vMaxMode = Number(Env.maxMode);

		if (vSelMode > vMaxMode) {
			popTips('模式不能超过' + vMaxMode + '!', "error");
			return false;
		}

		if (v_maxRecord != -1 && v_maxRecord < real_record) {
			popTips('注数不能超过' + v_maxRecord + '!', "error");
			return false;

		} else {

			//			if (v_maxMultiplePerOrder != -1 &&
			//				v_maxMultiplePerOrder < real_multiplePerOrder) {
			//				popTips('倍数不能超过' + v_maxMultiplePerOrder + '!', "error");
			//				return false;
			//
			//			} else {
			if (v_maxPrize != -1 && v_maxPrize < real_total_prize) {
				popTips('总投注额不能超过' + v_maxPrize + '!', "error");
				return false;
			}
			//			}
		}
		return true;
	};

	var chooseRule = function(rulecode) {
		var addCodeBtn = $('a.add-haoma');
		addCodeBtn.removeAttr('onclick');
		addCodeBtn.text('加载中...');
		
		// 提示帮助
		if (way.get("Lottery.context")) {
			way.set("Lottery.context", "");
		}
		if (way.get("Lottery.contexts")) {
			way.set("Lottery.contexts", "");
		}
		
		for (var i = 0; i < 5; i++) {
			$("#Lottery_places_" + i).removeAttr("checked").removeClass("selected");
		}
		way.set("Lottery.count.places", "");
		way.set("Lottery.balls.places", "");

		$('#wanfaTs').html(Lottery_Rules[rulecode].bettips);

		$('#helpExp').html(Lottery_Rules[rulecode].betexample);
		$('#helpInfo').html(Lottery_Rules[rulecode].bethelp);

		if ($("#" + rulecode).length > 0) {
			$('.touzhu-one').find('dl').hide();
			$("#" + rulecode).show();
			$('#textarea_Lottery').hide();
		} else {
			$('.touzhu-one').find('dl').hide();
			if (Lottery_Rules[rulecode].pageHtml) {
				$('.touzhu-one').append(Lottery_Rules[rulecode].pageHtml);
				$('#textarea_Lottery').hide();
			} else {
				$('#textarea_Lottery').show();
				$("#textarea_Lottery").keypress(function(e) {
					Lottery_Rules[rulecode].changeContext(e);
				});
				if (Lottery_Rules[rulecode].isPlaces) {
					$('#textarea_Lottery').find(".xwInput").show();
				} else {
					$('#textarea_Lottery').find(".xwInput").hide();
				}
			}
		}

		Lottery_Rules[rulecode].vali();
		var alreadyBack = false;
		// 异步加载数据参数
		if (rule[shortName + '_' + rulecode]) {
			Env.lottery = rule[shortName + '_' + rulecode].lottery;
			Env.price = rule[shortName + '_' + rulecode].price;
			Env.startMoney = rule[shortName + '_' + rulecode].startMoney;
			Env.otherPrize = rule[shortName + '_' + rulecode].otherPrize;
			Env.minMode = rule[shortName + '_' + rulecode].minMode;
			Env.maxMode = rule[shortName + '_' + rulecode].maxMode;
			Env.maxRuleMode = rule[shortName + '_' + rulecode].maxRuleMode;
			Env.repoint = rule[shortName + '_' + rulecode].repoint;
			Env.maxRepoint = rule[shortName + '_' + rulecode].maxRepoint;
			Env.maxRecord = rule[shortName + '_' + rulecode].maxRecord;
			//Env.defaultBetModel = rule[shortName + '_' + rulecode].defaultBetModel;

			Env.endMoney = rule[shortName + '_' + rulecode].endMoney;
			Env.otherEndMoney = rule[shortName + '_' + rulecode].otherEndMoney;
            Env.backpointLess = rule[shortName + '_' + rulecode].backpointLess; //是否需要减去返点
			var str = "";
			if (Env.otherPrize) {
				$.each(Env.otherPrize, function(index, value) {
					str += '/' + value;
				});
			}
			if (str == "") {
				str = Env.startMoney;
			} else {
				str = str.substr(1);
			}
			$('#prizeInfo').html("玩法奖金：" + str);
			alreadyBack = true;
			
			addCodeBtn.attr('onclick', 'Lottery_Rule.addOrder();');
			addCodeBtn.text('添加号码');
		} else {
			rule[shortName + '_' + rulecode] = {};
			$.ajax({
				url: "/ct-data/lottery",
				type: "post",
				dataType: "json",
				async: false,
				data: {
					"shortName": shortName,
					"rulecode": rulecode
				},
				success: function(data) {
					if (data.sign) {
						var str = "";
						if (data.otherPrize) {
							$.each(data.otherPrize, function(index, value) {
								str += '/' + value;
							});
						}
						if (str == "") {
							str = data.startMoney;
						} else {
							str = str.substr(1);
						}
						$('#prizeInfo').html("玩法奖金：" + str);

						Env.lottery = data.lottery;
						Env.price = data.price;
						if (data.startMoney) {
							Env.startMoney = data.startMoney;
						} else {
							Env.startMoney = 0;
						}
						if (data.otherPrize) {
							Env.otherPrize = data.otherPrize;
						} else {
							Env.otherPrize = 0;
						}

						Env.minMode = data.minMode;
						Env.maxMode = parseInt(data.maxMode);
						Env.maxRuleMode = parseInt(data.maxRuleMode);
						Env.repoint = data.repoint;
						Env.maxRepoint = data.maxRepoint;
						Env.maxModeLi = data.maxModeLi;
						Env.maxPrize = data.maxPrize;
						Env.maxRecord = data.maxRecord;
						Env.endMoney = data.endMoney;
						Env.otherEndMoney = data.otherEndMoney;
                        Env.backpointLess = data.backpointLess;     // 是否需要减去返点
						//Env.defaultBetModel = parseInt(data.defaultBetModel);
						rule[shortName + '_' + rulecode].maxModeLi = Env.maxModeLi;
						rule[shortName + '_' + rulecode].lottery = Env.lottery;
						rule[shortName + '_' + rulecode].price = Env.price;
						rule[shortName + '_' + rulecode].startMoney = Env.startMoney;
						rule[shortName + '_' + rulecode].otherPrize = Env.otherPrize;
						rule[shortName + '_' + rulecode].minMode = Env.minMode;
						rule[shortName + '_' + rulecode].maxMode = Env.maxMode;
						rule[shortName + '_' + rulecode].maxRuleMode = Env.maxRuleMode;
						rule[shortName + '_' + rulecode].repoint = Env.repoint;
						rule[shortName + '_' + rulecode].maxRepoint = Env.maxRepoint;
						rule[shortName + '_' + rulecode].maxRecord = Env.maxRecord;
						//rule[shortName + '_' + rulecode].defaultBetModel = Env.defaultBetModel;
						rule[shortName + '_' + rulecode].endMoney = Env.endMoney;
						rule[shortName + '_' + rulecode].otherEndMoney = Env.otherEndMoney;
                        rule[shortName + '_' + rulecode].backpointLess = Env.backpointLess; //是否需要减去返点

						addCodeBtn.attr('onclick', 'Lottery_Rule.addOrder();');
						addCodeBtn.text('添加号码');
					} else {
						popTips(data.message, 'error');
						addCodeBtn.text('加载失败');
					}
				},
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					popTips("玩法数据初始化失败", 'error');
					addCodeBtn.text('加载失败');
				},
				complete: function() {
					alreadyBack = true;
				}
			});
		}

		var alreadyBackIndex = setInterval(function() {
			if (alreadyBack) {
				clearInterval(alreadyBackIndex);

				// 默认为最大的奖金模式
				if(!getValueInLocalStorage("defaultBetModel")){
					setValueInLocalStorage("defaultBetModel",Env.maxMode);
				}


				if (eval(getValueInLocalStorage("defaultBetModel")) > Env.maxMode) {
					way.set("http://www.yugj881.com/resources/main/Lottery.mode", Env.maxMode);
				} else {
					way.set("http://www.yugj881.com/resources/main/Lottery.mode", eval(getValueInLocalStorage("defaultBetModel")));
				}

				way.set("Lottery.prize", Env.startMoney);
				way.set("orderlist.lottery", Env.lottery);
				way.set("Lottery.repoint", (Env.repoint * 100).toFixed(1));
				//way.set("Lottery.maxPrize", Env.maxPrize);
				// 下单页面isShow:false,

				// $('.touzhu-one').append(Lottery_Rules[rulecode].pageHtml);
				if (Lottery_Rules[rulecode]) {
					curRule = Lottery_Rules[rulecode];
					if (curRule.isPlaces) {
						way.set(curRule.rulecode + ".balls.places", way.get("Lottery.balls.places"));
					}
					if (!way.get("Lottery.times")) {
						way.set("Lottery.times", "1");
					}
					if (!way.get("http://www.yugj881.com/resources/main/Lottery.yjf")) {
						way.set("http://www.yugj881.com/resources/main/Lottery.yjf", 1);
					}
					curRule.calculatePrize(curRule.rulecode);

					// 不定位
					var repoint = Env.repoint;
                    if (Env.backpointLess>0) {
                        repoint = repoint - Env.backpointLess;
                        var maxMode = Env.minMode + repoint * 100 * 20;
                        if (maxMode < Env.maxMode) {
                            Env.maxMode = maxMode;
                        }
                        if (repoint < 0) {
                            Env.maxMode = Env.minMode;
                            repoint = 0;
                        }
                        way.set("Lottery.repoint", (repoint * 100).toFixed(1));
                    }
					// 不定位结束
					if (Env.maxModel <= 1700) {
						Env.maxMode = 1700;
						way.set("http://www.yugj881.com/resources/main/Lottery.mode", Env.minMode);
					} else {
						if (way.get("http://www.yugj881.com/resources/main/Lottery.mode")) {
							if (parseInt(way.get("http://www.yugj881.com/resources/main/Lottery.mode")) >= Env.minMode) {
								if (parseInt(way.get("http://www.yugj881.com/resources/main/Lottery.mode")) > Env.maxMode) {
									way.set("http://www.yugj881.com/resources/main/Lottery.mode", Env.maxMode);
									way.set("Lottery.repoint", 0);
								} else {
									way.set("Lottery.repoint", ((repoint * 100) - (way.get("http://www.yugj881.com/resources/main/Lottery.mode") - Env.minMode) / 20).toFixed(1));
								}
							} else {
								way.set("http://www.yugj881.com/resources/main/Lottery.mode", Env.minMode);
								way.set("Lottery.repoint", (repoint * 100).toFixed(1));
							}
						} else {
							way.set("http://www.yugj881.com/resources/main/Lottery.mode", Env.minMode);
							way.set("Lottery.repoint", (repoint * 100).toFixed(1));
						}
						way.set("equalizer", way.get("http://www.yugj881.com/resources/main/Lottery.mode"));
						if (Env.maxMode > Env.maxModeLi && eval(way.get("http://www.yugj881.com/resources/main/Lottery.yjf")) == 'http://www.yugj881.com/resources/main/0.001') {
							if (eval(way.get("http://www.yugj881.com/resources/main/Lottery.mode")) > Env.maxModeLi) {
								way.set("http://www.yugj881.com/resources/main/Lottery.mode", Env.maxModeLi);
							}
							way.set("equalizer", way.get("http://www.yugj881.com/resources/main/Lottery.mode"));
							moneySlider("slider-range", Env.minMode, Env.maxModeLi, way.get("http://www.yugj881.com/resources/main/Lottery.mode"), dragEqualizer);
						} else {
							moneySlider("slider-range", Env.minMode, Env.maxMode, way.get("http://www.yugj881.com/resources/main/Lottery.mode"), dragEqualizer);
						}
					}
				} else
					curRule = null;
			}
		}, 50);
	};

	var equalizer_poi = function(value) {
		var poi = 0;
		var repoint = Env.repoint;
		// 不定位判断
        if (Env.backpointLess) {
            if (Env.backpointLess > 0) {
                repoint = (repoint - Env.backpointLess).toFixed(3);
                if (repoint < 0) {
                    repoint = 0;
                }
            }
        }
		// 不定位判断

		// if (repoint > sysRepoint) {
		// 	repoint = sysRepoint;
		// }

		// todo
		var s = 0;
		var sysRepoint = 0;
		if(eval(way.get("http://www.yugj881.com/resources/main/Lottery.yjf")) == 'http://www.yugj881.com/resources/main/0.001'){
			s = Env.maxModeLi - Env.minMode;
			sysRepoint = (Env.maxModeLi - Env.minMode) / 2000;
		}else{
			s = Env.maxMode - Env.minMode;
			sysRepoint = (Env.maxMode - Env.minMode) / 2000;
		}
		// var s = Env.maxMode - Env.minMode;
		var s2 = value - Env.minMode;
		if (s === 0) {
			way.set("Lottery.repoint", (repoint * 100).toFixed(1));
		} else {
			way.set("Lottery.repoint", ((repoint - s2 * sysRepoint / s) * 100).toFixed(1));
		}
		way.set("http://www.yugj881.com/resources/main/Lottery.mode", value);

	};

	var init = function(lotteryName) {
		if (!user) {
			setTimeout(function() {
				init(lotteryName);
			}, 100);
			return;
		}
		setCookie("currentContent", "touzhufangan", 1);
		history.replaceState('', '', (currentRootDirectory + window.location.pathname + "?code=" + lotteryName));
        getLotteryLink();
		Lottery_Rule.list_clear();
		// 用来判断到期提示是否用提示（进入页面开始不提示）
		isFirstOpenTime = true;
		if (!lotteryName) {
			shortName = "cqssc";
		} else {
			shortName = lotteryName;
		}
		Env.lottery = shortName;
        way.set("lottery_cn_name", STATIC_DATA.lottery_data[shortName].lotteryName);

        // 彩种图片
        var $img =  $(".lot-logo").find("img");

        if (STATIC_DATA.l_g_ssc.indexOf(shortName) > -1) {
            // 高频时时彩
            $img.attr("src", "../yiyou/images/game/lottery/l_g_ssc.png"/*tpa=http://www.yugj881.com/resources/yiyou/images/game/lottery/l_g_ssc.png*/);
        } else if (STATIC_DATA.l_g_11x5.indexOf(shortName) > -1) {
            // 高频11选5/PK10
            if (shortName.indexOf('11x5') > -1) {
                $img.attr("src", "../yiyou/images/game/lottery/l_g_11x5.png"/*tpa=http://www.yugj881.com/resources/yiyou/images/game/lottery/l_g_11x5.png*/);
            } else {
                $img.attr("src", "../yiyou/images/game/lottery/l_g_pk10.png"/*tpa=http://www.yugj881.com/resources/yiyou/images/game/lottery/l_g_pk10.png*/);
            }
        } else if (STATIC_DATA.l_g_k3.indexOf(shortName) > -1) {
            // 高频快三
            $img.attr("src", "../yiyou/images/game/lottery/l_g_k3.png"/*tpa=http://www.yugj881.com/resources/yiyou/images/game/lottery/l_g_k3.png*/);
        } else if (STATIC_DATA.l_g_xy3d.indexOf(shortName) > -1) {
            // 高频3D
            $img.attr("src", "../yiyou/images/game/lottery/l_g_xy3d.png"/*tpa=http://www.yugj881.com/resources/yiyou/images/game/lottery/l_g_xy3d.png*/);
        } else if (STATIC_DATA.l_ssc.indexOf(shortName) > -1) {
            // 官方时时彩
            $img.attr("src", "../yiyou/images/game/lottery/ssc.png"/*tpa=http://www.yugj881.com/resources/yiyou/images/game/lottery/ssc.png*/);
        } else if (STATIC_DATA.l_11x5.indexOf(shortName) > -1) {
            // 11选5/PK拾
            if (shortName.indexOf('11x5') > -1) {
                $img.attr("src", "../yiyou/images/game/lottery/syxw.png"/*tpa=http://www.yugj881.com/resources/yiyou/images/game/lottery/syxw.png*/);
            } else {
                $img.attr("src", "../yiyou/images/game/lottery/pks.png"/*tpa=http://www.yugj881.com/resources/yiyou/images/game/lottery/pks.png*/);
            }
        }else if (STATIC_DATA.l_k3.indexOf(shortName) > -1) {
            // 快三
            $img.attr("src", "../yiyou/images/game/lottery/ks.png"/*tpa=http://www.yugj881.com/resources/yiyou/images/game/lottery/ks.png*/);
        } else if (STATIC_DATA.l_dpc.indexOf(shortName) > -1) {
            // 低频彩(低频彩 + 3d)
            if (shortName.indexOf('3d') > -1) {
                $img.attr("src", "../yiyou/images/game/lottery/gf3d.png"/*tpa=http://www.yugj881.com/resources/yiyou/images/game/lottery/gf3d.png*/);
            } else {
                $img.attr("src", "../yiyou/images/game/lottery/dpc.png"/*tpa=http://www.yugj881.com/resources/yiyou/images/game/lottery/dpc.png*/);
            }
        } else if (STATIC_DATA.l_kl10f.indexOf(shortName) > -1) {
            // 快乐十分
            $img.attr("src", "../yiyou/images/game/lottery/klsf.png"/*tpa=http://www.yugj881.com/resources/yiyou/images/game/lottery/klsf.png*/);
        }


        // 彩种数据

        // 玩法
        if (STATIC_DATA.l_g_ssc.indexOf(shortName) > -1 || STATIC_DATA.l_ssc.indexOf(shortName) > -1 || shortName=='hnqxc') {
            // 高频时时彩 或 官方时时
            ClockEnv.num = 5;
            ClockEnv.numRange = '0-9';
            $.getScript('lottery/lt_ssc.js'/*tpa=http://www.yugj881.com/resources/main/lottery/lt_ssc.js*/, function() {
                sscPlayRules();
            });
        } else if (STATIC_DATA.l_g_11x5.indexOf(shortName) > -1 || STATIC_DATA.l_11x5.indexOf(shortName) > -1) {
            // 高频11选5/PK拾 或 11选5/PK拾
            if (shortName.indexOf('11x5') > -1) {
                // 11选5
                ClockEnv.num = 5;
                ClockEnv.numRange = '1-11';
                $.getScript('lottery/lt_syxw.js'/*tpa=http://www.yugj881.com/resources/main/lottery/lt_syxw.js*/, function() {
                    syxwPlayRules();
                });
            } else {
                // PK拾
                ClockEnv.num = 10;
                ClockEnv.numRange = '1-10';
                $.getScript('lottery/lt_pks.js'/*tpa=http://www.yugj881.com/resources/main/lottery/lt_pks.js*/, function() {
                    pksPlayRules();
                });
            }
        } else if (STATIC_DATA.l_g_k3.indexOf(shortName) > -1 || STATIC_DATA.l_k3.indexOf(shortName) > -1) {
            // 高频快三 或 快三
            ClockEnv.num = 3;
            ClockEnv.numRange = '1-6';
            $.getScript('lottery/lt_ks.js'/*tpa=http://www.yugj881.com/resources/main/lottery/lt_ks.js*/, function() {
                ksPlayRules();
            });
        } else if (STATIC_DATA.l_g_xy3d.indexOf(shortName) > -1 || STATIC_DATA.l_dpc.indexOf(shortName) > -1) {
            // 高频 3D 或者 低频彩
            ClockEnv.num = 3;
            ClockEnv.numRange = '0-9';
            $.getScript('lottery/lt_dpc.js'/*tpa=http://www.yugj881.com/resources/main/lottery/lt_dpc.js*/, function() {
                dpcPlayRules();
            });
        } else if (STATIC_DATA.l_kl10f.indexOf(shortName) > -1) {
            // 快乐十分
            ClockEnv.num = 8;
            ClockEnv.numRange = '1-20';
            $.getScript('lottery/lt_klsf.js'/*tpa=http://www.yugj881.com/resources/main/lottery/lt_klsf.js*/, function() {
                klsfPlayRules();
            });
        }
		loadOpenTime(shortName);
		openCodeList(shortName);
		if (!isFirst) {
			way.watch("equalizer", function(value) {
				equalizer_poi(value);
			});
			way.watch("orderlist.items", orderlistItemListener);
			$(document).on("click", ".sz-qiu li", clickBall);
			$(document).on("click", ".gongn li", clickBallButton);
			// 任选玩法的万千百十个位
			$(document).on("click", ".xwInput li input", clickPlaces);
			isFirst = true;
			way.watchAll(iwac_text);
			$(document).on('click', '.tabHd', iwac_dialog_radio_click);
			$(document).on('click', '#iwac_except2_button',
				iwac_except2_button_click);
			$(document).on('change', '#appendcode_table input[type="checkbox"]',
				iwac_checkbox);
			$(document).on('input', '#appendcode_table .bs', iwac_times);
			$(document).on('click', '#iwac_stopappendcode', iwac_stopappendc);

			for (var i = 0; i < 5; i++) {
				$("#Lottery_places_" + i).removeAttr("checked").removeClass("selected");
			}
			way.set("Lottery.count.places", "");
			way.set("Lottery.balls.places", "");
		}
	};
	var dragEqualizer = function(leftparam, id) {
		way.set("equalizer", leftparam);
		setValueInLocalStorage("defaultBetModel", parseInt(leftparam));
	};
	var orderlistItemListener = function(items) {
		var i = 0;

		if (items) {
			$.each(items, function(key, value) {
				var insert = true;
				$('.xiadan-nr').find('dl').find('dd').each(function() {
					if (key == this.id) {
						insert = false;
						return false;
					}
				});
				if (insert) {
					var context = this.bigCodes;
					if (this.balls) {
						if(context) {
							context += ",";
						} else {
							context = "";
						}
						if(Lottery_Rules[this.rulecode].formatBalls) {
							context = Lottery_Rules[this.rulecode].formatBalls(this.balls);
						} else {
							$.each(this.balls, function(k, v) {
								$.each(v, function(kk, vv) {
									if (k == "places") {
										switch (vv) {
											case '0':
												vv = '万位';
												break;
											case '1':
												vv = '千位';
												break;
											case '2':
												vv = '百位';
												break;
											case '3':
												vv = '十位';
												break;
											case '4':
												vv = '个位';
												break;
											default:
												;
										}
									}
									if (vv) {
										context = context + vv + ' ';
									}
								});
								context = context + ',';
							});
						}
					}
					if (context.length > 20) {
						context = context.substring(0, 20);
						context = context + "...";
					}
					if (Lottery_Rules[this.rulecode].replaceCode) {
						context = Lottery_Rules[this.rulecode]
							.replaceCode(context);
					}
					var y = "";
					var j = "";
					var f = "";
					var l = "";
					if (this.yjf == 1)
						y = "selected='selected'";
					else if (this.yjf == 0.1)
						j = "selected='selected'";
					else if (this.yjf == 0.01)
						f = "selected='selected'";
					else if (this.yjf == 0.001)
						l = "selected='selected'";
					var ys = "";
					var js = "";
					var fs = "";
					var ls = "";
					if (this.yjf == 0.001) {
						ys += " display: none; ";
						js += " display: none; ";
						fs += " display: none; ";
					} else {
						ls = " display: none;";
					}
					
					var maxPrize = 0;
					$.ajax({
						url: "/ct-data/userBets/getMaxPrize",
						type: "post",
						dataType: "json",
						async: false,
						data:{
							"shortName": Env.lottery,
							"ruleCode": curRule.rulecode,
							"num": this.itemcount
						},
						success: function(data) {
							if(data.sign == true) {
								maxPrize = data.maxPrize;
							}
						},
						error: function(XMLHttpRequest, textStatus, errorThrown) {}
					});
					$('.xiad-left').find('dl').handlebarsAppend(
						$('#tpl_starbar'), {
							id: key,
							total: this.total,
							itemcount: this.itemcount,
							times: this.times,
							yjf: this.yjf,
							repoint: this.repoint,
							mode: this.mode,
							codes: context,
							title: Lottery_Rules[this.rulecode].realname,
							y: y,
							j: j,
							f: f,
							l: l,
							ys: ys,
							js: js,
							fs: fs,
							ls: ls,
							maxPrize: maxPrize
						});
				}
				i++;
			});
		}
		if (i === 0) {
			$('.xiadan-nr').find('dl').html("");
		} else {
			$('.xiadan-nr').find('dl').find('dd').each(function() {
				if (!items[this.id]) {
					$(this).remove();
				}
			});
		}
	};

    var clickBall = function (e) {
        ss = e.target.id.split("_");
        var balls = way.get(ss[0] + ".balls." + ss[1]);
        // 11选5, 使当前玩法奖金变更
        // var prize = $('#prizeInfo').html().split('/');
        // var zu = [prize[0].replace("玩法奖金：", ""), prize[1], prize[2], prize[3], prize[4], prize[5]];
        // if (ss[0] == '11x5dds' && ss[1] == 'zu') {
        //     way.set("Lottery.prize", zu[ss[2]]);
        // }
        // if (ss[0] == '11x5czw' && ss[1] == 'b') {
        //     var b = ['', '', '', prize[0].replace("玩法奖金：", ""), prize[1], prize[2], prize[3], prize[4], prize[5], prize[6]];
        //     way.set("Lottery.prize", b[ss[2].replace('0', '')]);
        // }

        if (!balls || balls === null) {
            balls = new Array();
            way.set(ss[0] + ".balls." + ss[1], balls);
        }
        var count = way.get(ss[0] + ".count." + ss[1]);
        if (!count) {
            count = 0;
        }

        if ($(e.target).hasClass("cur")) {
            $(e.target).removeClass("cur");
            balls[eval(ss[2])] = "";
            way.set(ss[0] + ".count." + ss[1], count - 1);
        } else {
            // curRule.rulecode == 'dweid' ||
            if ((curRule.rulecode == 'bjpk10qian1' || curRule.rulecode == 'bjpk10qian2' ||
                curRule.rulecode == 'bjpk10qian3' || curRule.rulecode == 'bjpk10dwd') && count == 9) {
                popTips("每位最多选9个号码", "waring");
            } else {
                $(e.target).addClass("cur");
                balls[eval(ss[2])] = ss[2];
                way.set(ss[0] + ".count." + ss[1], count + 1);
            }
        }
        curRule.vali(e);
    };

	var clickBallButton = function(e) {
		var ss = $(e.target).attr("datascope").split("_");
		var i, j, o;
		var pre, item;
		
		var sss = ss[3].split("-");
		pre = ss[0] + "_" + ss[1] + "_";
		i = eval(sss[0]);
		j = eval(sss[1]);
		// 先清除已选
		for (; i <= j; i++) {
			if (sss[1] > 9) {
				o = i;
				if (o < 10) {
					o = "0" + o;
				}
				item = $("#" + pre + o);
			} else {
				item = $("#" + pre + i);
			}
			if (item.hasClass("cur")) {
				item.trigger('click');
			}
		}
		
		i = eval(sss[0]);
		if (ss[2] == "big") {
			for (; i <= j; i++) {
				if (sss[1] > 9) {
					o = i;
					if (o < 10) {
						o = "0" + o;
					}
					item = $("#" + pre + o);
				} else {
					item = $("#" + pre + i);
				}
				if (i <= (eval(sss[0]) + j) / 2 && item.hasClass("cur")) {
					item.trigger('click');
				} else if (i > (eval(sss[0]) + j) / 2 && !item.hasClass("cur")) {
					item.trigger('click');
				}
			}
		} else if (ss[2] == "sma") {
			for (; i <= j; i++) {
				if (sss[1] > 9) {
					o = i;
					if (o < 10) {
						o = "0" + o;
					}
					item = $("#" + pre + o);
				} else {
					item = $("#" + pre + i);
				}
				if (i <= (eval(sss[0]) + j) / 2 && !item.hasClass("cur")) {
					item.trigger('click');
				} else if (i > (eval(sss[0]) + j) / 2 && item.hasClass("cur")) {
					item.trigger('click');
				}
			}
		} else if (ss[2] == "sin") {
			for (; i <= j; i++) {
				if (sss[1] > 9) {
					o = i;
					if (o < 10) {
						o = "0" + o;
					}
					item = $("#" + pre + o);
				} else {
					item = $("#" + pre + i);
				}
				if ((i % 2 == 1) && !item.hasClass("cur")) {
					item.trigger('click');
				} else if ((i % 2 === 0) && item.hasClass("cur")) {
					item.trigger('click');
				}
			}
		} else if (ss[2] == "dou") {
			for (; i <= j; i++) {
				if (sss[1] > 9) {
					o = i;
					if (o < 10) {
						o = "0" + o;
					}
					item = $("#" + pre + o);
				} else {
					item = $("#" + pre + i);
				}
				if ((i % 2 == 1) && item.hasClass("cur")) {
					item.trigger('click');
				} else if ((i % 2 === 0) && !item.hasClass("cur")) {
					item.trigger('click');
				}
			}
		} else if (ss[2] == "ful") {
			for (; i <= j; i++) {
				if (sss[1] > 9) {
					o = i;
					if (o < 10) {
						o = "0" + o;
					}
					item = $("#" + pre + o);
				} else {
					item = $("#" + pre + i);
				}
				if (!item.hasClass("cur")) {
					item.trigger('click');
				}
			}
		}
	};

	var clickYJF = function(e) {
		curRule.vali();
	};

	var clickPlaces = function(e) {
		var ss = e.target.id.split("_");
		var balls = way.get("Lottery.balls." + ss[1]);
		if (!balls || balls === null) {
			balls = new Array();
			way.set("Lottery.balls." + ss[1], balls);
		}
		way.set(curRule.rulecode + ".balls." + ss[1], way.get("Lottery.balls." + ss[1]));
		var count = way.get("Lottery.count." + ss[1]);
		if (!count) {
			count = 0;
		}

		if (!$(e.target).hasClass("selected")) {
			$(e.target).addClass("selected");
			balls[ss[2]] = ss[2];
			way.set("Lottery.count." + ss[1], count + 1);
			curRule.vali();
		} else {
			$(e.target).removeClass("selected");
			balls[ss[2]] = "";
			way.set("Lottery.count." + ss[1], count - 1);
			curRule.vali();
		}
	};

	var count = 0;
	var addOrder = function() {

		// Lottery_Rules[rulecode].vali();
		if (way.get("Lottery.total") && way.get("Lottery.total") > 0) {
			if (!Lottery_Rule.verificateOrder()) {
				return false;
			}
			
			var uid = $.now() + "-" + Math.uuid(8);
			var ud = {};
			ud['rulecode'] = curRule.rulecode; // 玩法
			ud['prize'] = way.get("Lottery.prize");
			// 金额
			ud['total'] = way.get("Lottery.total");
			// 条数
			ud['itemcount'] = way.get("Lottery.itemcount");
			// 注数
			ud['times'] = way.get("Lottery.times");
			// 元角分模式
			ud['yjf'] = way.get("http://www.yugj881.com/resources/main/Lottery.yjf");
			// 返点
			ud['repoint'] = way.get("Lottery.repoint");
			ud['mode'] = way.get("http://www.yugj881.com/resources/main/Lottery.mode");
			ud['balls'] = $.extend(true, {}, way.get(curRule.rulecode + ".balls"));
			if (way.get("Lottery.contexts")) {
				ud['bigCodes'] = way.get("Lottery.contexts").join();
			}
			
			// 单式投注内容
			/*	if (way.get("Lottery.contexts")) {
					way.get("Lottery.contexts").sort();
					ud['bigCodes'] = way.get("Lottery.contexts").join();
					$.ajax({
						type: "post",
						url: "/ct-data/userBets/saveDs",
						data: {
							id: uid,
							rulecode: curRule.rulecode,
							bigCodes: ud['bigCodes'],
							balls: JSON.stringify(ud['balls'])
						}
					});
				}*/

			// 相同订单判断
			if(eval(way.get("orderlist.ordercount")) > 0) {
				var hasSameOrder = false;
				$.each(way.get("orderlist.items"), function(idx, val){
					if(val.rulecode==ud['rulecode'] && val.itemcount==ud['itemcount'] && val.yjf==ud['yjf']
							&& val.repoint==ud['repoint'] && val.mode==ud['mode']) {
						var hasSameBalls = true;
						$.each(val.balls, function(idxx, vall){
							if(ud['balls'][idxx] && vall.toString().replace(/,/g, '')==ud['balls'][idxx].toString().replace(/,/g, '')) {
								hasSameBalls = true;
							} else {
								hasSameBalls = false;
								return false;
							}
						});
						
						if(ud['bigCodes'] && val.bigCodes) {
							if(hasSameBalls==true && ud['bigCodes']==val.bigCodes) {
								hasSameOrder = true;
							} else {
								hasSameOrder = false;
							}
						} else {
							hasSameOrder = hasSameBalls;
						}
						
						// 有一样的订单
						if(hasSameOrder == true) {
							$("#"+idx+" li:eq(2) input").val(eval(ud['times']) + eval(val.times));
							$("#"+idx+" li:eq(2) input").blur();
							popTips("该投注已经存在，已直接为您加倍", "waring");
							return false;
						}
					}
				});
				
				if(hasSameOrder == true) {
					curRule.clear();
					return false;
				}
			}
			
			way.set("orderlist.items." + uid, ud);

			if (way.get("http://www.yugj881.com/resources/main/iwac.cost")) {
				if (ud['times'] && eval(ud['times']) > 1)
					way.set("http://www.yugj881.com/resources/main/iwac.cost", eval(ud['total']) / eval(ud['times']) + eval(way.get("http://www.yugj881.com/resources/main/iwac.cost")));
				else
					way.set("http://www.yugj881.com/resources/main/iwac.cost", eval(ud['total']) + eval(way.get("http://www.yugj881.com/resources/main/iwac.cost")));
			} else {
				if (ud['times'] && eval(ud['times']) > 1)
					way.set("http://www.yugj881.com/resources/main/iwac.cost", eval(ud['total']) / eval(ud['times']));
				else
					way.set("http://www.yugj881.com/resources/main/iwac.cost", eval(ud['total']));
			}
			var prizes = way.get("Lottery.prize").toString().split("/");
			var prize = 0;
			for(var i=0; i<prizes.length; i++) {
				var p = eval(prizes[i]);
				if(p > prize) {
					prize = p;
				}
			}
			if (way.get("iwac.prize")) {
				way.set("iwac.prize", prize + eval(way.get("iwac.prize")));
			}
			else {
				way.set("iwac.prize", prize);
			}

			if (way.get("orderlist.total"))
				way.set("orderlist.total", (eval(way.get("Lottery.total")) + eval(way.get("orderlist.total"))).toFixed(4));
			else
				way.set("orderlist.total", eval(way.get("Lottery.total")));

			if (way.get("orderlist.itemcount"))
				way.set("orderlist.itemcount", eval(way.get("Lottery.itemcount")) + eval(way.get("orderlist.itemcount")));
			else
				way.set("orderlist.itemcount", eval(way.get("Lottery.itemcount")));

			if (way.get("orderlist.ordercount"))
				way.set("orderlist.ordercount", 1 + eval(way.get("orderlist.ordercount")));
			else
				way.set("orderlist.ordercount", 1);
			curRule.clear();
			count++;
			way.set("orderlist.sumCount", count);
			return true;
		} else {
			var times = way.get("Lottery.times");
			if (times < 1) {
				popTips('倍数不能小于1!', "error");
			} else {
				popTips('号码不完整，请重新选择!', "error");
			}
			return false;
		}
	};
    var udorder = function (orderid, ty, th) {
        if (ty == "t" && (!th.value || eval(th.value) < 1)) {
            th.value = 1;
        }
        th.value = eval(th.value);
        var oldtotal, oldtimes, oldbigtotal;
        if (ty == "t") {
            oldtotal = eval(way.get("orderlist.items." + orderid + ".total"));
            oldtimes = eval(way.get("orderlist.items." + orderid + ".times"));
            oldbigtotal = eval(way.get("orderlist.total"));
            way.set("orderlist.items." + orderid + ".times", th.value);
            way.set("orderlist.items." + orderid + ".total", (th.value * oldtotal / oldtimes).toFixed(4));
            way.set("orderlist.total", (oldbigtotal - oldtotal + eval(way.get("orderlist.items." + orderid + ".total"))).toFixed(4));
            $(th).parent("li").next("li").next("li").html("￥" + eval(way.get("orderlist.items." + orderid + ".total")).toFixed(4) + "元");

        } else if (ty == "y") {
            oldtotal = eval(way.get("orderlist.items." + orderid + ".total"));
            oldyjf = eval(way.get("orderlist.items." + orderid + ".yjf"));
            oldbigtotal = eval(way.get("orderlist.total"));
            way.set("orderlist.items." + orderid + ".yjf", th.value);
            way.set("orderlist.items." + orderid + ".total", (th.value * oldtotal / oldyjf).toFixed(4));
            way.set("orderlist.total", eval(oldbigtotal - oldtotal + eval(way.get("orderlist.items." + orderid + ".total"))).toFixed(4));
            $(th).children("option").each(function (ind, val) {
                if (eval(val.value) == th.value) {
                    $(val).attr("selected", true);
                } else
                    $(val).attr("selected", false);
            });
            $(th).parent("li").next("li").html("￥" + eval(way.get("orderlist.items." + orderid + ".total"))
                    .toFixed(4) + "元");
            var times = eval(way.get("orderlist.items." + orderid + ".times"));
            way.set("http://www.yugj881.com/resources/main/iwac.cost", eval(way.get("http://www.yugj881.com/resources/main/iwac.cost")) - oldtotal / times + (th.value * oldtotal / oldyjf).toFixed(4) / times);
        }
    };

    var dialogDetail = function (orderid) {
        var context = way.get("orderlist.items." + orderid + ".bigCodes");
        var balls = way.get("orderlist.items." + orderid + ".balls");
        if (balls) {
            if (context) {
                context += ",";
            } else {
                context = "";
            }
            var ruleCode = way.get("orderlist.items." + orderid + ".rulecode");
            if (Lottery_Rules[ruleCode].formatBalls) {
                context = Lottery_Rules[ruleCode].formatBalls(balls);
            } else {
                $.each(balls, function (k, v) {
                    $.each(v, function (kk, vv) {
                        if (k == "places") {
                            switch (vv) {
                                case '0':
                                    vv = '万位';
                                    break;
                                case '1':
                                    vv = '千位';
                                    break;
                                case '2':
                                    vv = '百位';
                                    break;
                                case '3':
                                    vv = '十位';
                                    break;
                                case '4':
                                    vv = '个位';
                                    break;
                            }
                        }
                        if (vv) {
                            context = context + vv + ' ';
                        }
                    });
                    context = context + ',';
                });
            }
        }

		// if has Fn 則進行replaceCode換算
		if (Lottery_Rules[ruleCode].replaceCode) {
			context = Lottery_Rules[ruleCode].realname + Lottery_Rules[ruleCode].replaceCode(context);
		}
        way.set("dingdan.currExpect", way.get("showExpect.currExpect"));
        var yjf = "";
        if (way.get("orderlist.items." + orderid + ".yjf") == 1) {
            yjf = "元";
        } else if (way.get("orderlist.items." + orderid + ".yjf") == 0.1) {
            yjf = "角";
        } else if (way.get("orderlist.items." + orderid + ".yjf") == 0.01) {
            yjf = "分";
        } else if (way.get("orderlist.items." + orderid + ".yjf") == 0.001) {
            yjf = "厘";
        }
        way.set("http://www.yugj881.com/resources/main/dingdan.yjf", yjf);
        way.set("dingdan.times", way.get("orderlist.items." + orderid + ".times"));
        way.set("dingdan.itemcount", way.get("orderlist.items." + orderid + ".itemcount"));
        way.set("dingdan.total", way.get("orderlist.items." + orderid + ".total"));
        way.set("dingdan.context", context);
        pop("ddxiangq");
    };

	var delOrder = function(id) {
		count--;
		way.set("orderlist.sumCount", count == 0 ? '0' : count);
		if (way.get("http://www.yugj881.com/resources/main/iwac.cost")) {
			if (way.get("orderlist.items." + id + ".times") && eval(way.get("orderlist.items." + id + ".times")) > 1)
				way.set("http://www.yugj881.com/resources/main/iwac.cost", eval(way.get("http://www.yugj881.com/resources/main/iwac.cost")) - eval(way.get("orderlist.items." + id + ".total")) / eval(way.get("orderlist.items." + id + ".times")));
			else
				way.set("http://www.yugj881.com/resources/main/iwac.cost", eval(way.get("http://www.yugj881.com/resources/main/iwac.cost")) - eval(way.get("orderlist.items." + id + ".total")));
		}

		if (way.get("iwac.prize")) {
			way.set("iwac.prize", eval(way.get("iwac.prize")) - eval(way.get("orderlist.items." + id + ".prize")));
		}

		if (way.get("orderlist.total"))
			way.set("orderlist.total", (eval(way.get("orderlist.total")) - eval(way.get("orderlist.items." + id + ".total"))).toFixed(4));

		if (way.get("orderlist.itemcount"))
			way.set("orderlist.itemcount", eval(way.get("orderlist.itemcount")) - eval(way.get("orderlist.items." + id + ".itemcount")));

		if (way.get("orderlist.ordercount"))
			way.set("orderlist.ordercount", eval(way
				.get("orderlist.ordercount") - 1));

		if (!way.get("orderlist.total"))
			way.set("orderlist.total", "0");

		if (!way.get("orderlist.itemcount"))
			way.set("orderlist.itemcount", "0");

		if (!way.get("orderlist.ordercount"))
			way.set("orderlist.ordercount", "0");

		way.set("orderlist.items." + id, null);
	}

	var list_clear = function() {
		way.set("orderlist.items", {});

		way.set("orderlist.total", "0");

		way.set("http://www.yugj881.com/resources/main/iwac.cost", "0");

		way.set("iwac.prize", "0");

		way.set("orderlist.itemcount", "0");

		way.set("orderlist.ordercount", "0");

		way.set("orderlist.sumCount", "0");
		
		way.set("Lottery.maxPrize", "0");
		count = 0;
	}

	var iwac_text = function(selector, value) {
		if (/^orderlist\.iwac\.item\..+\.total$/.test(selector)) {
			var totaljs = 0;
			var collectitems = way.get('http://www.yugj881.com/resources/main/orderlist.iwac.item');
			$.each(collectitems,
				function() {
					if (this.total && !isNaN(this.total))
						totaljs = totaljs + eval(this.total);
					way.set('orderlist.iwac.total', new Number(totaljs.toFixed(4)));
					$('#orderlist_total').html(
						way.get('orderlist.iwac.total'));
				});
		} else if (/^orderlist\.iwac\.item\..+\.times$/.test(selector)) {
			selector = selector.substr(0, selector.length - 6);
			selector = selector.substring(20, selector.length);
			if (selector.indexOf("times_") >= 0) {
				selector = selector.substring(6, selector.length);
			}
			if ($('#' + selector).prop("checked") && value && !isNaN(parseInt(value)) && parseInt(value) != 0) {

				way.set("orderlist.iwac.item." + selector + ".total", (eval(way
					.get("http://www.yugj881.com/resources/main/iwac.cost")) * eval(value)).toFixed(4));
				$('#total_' + selector).html(
					way.get("orderlist.iwac.item." + selector + ".total"));
			} else {
				way.set("orderlist.iwac.item." + selector + ".total", "0");
				$('#total_' + selector).html("0");
			}
		} else if (/^[^\.]+\.yjf$/.test(selector)) {
			var group = selector.match(/^([^\.]+)\..+$/);

			if (Env.maxMode > Env.maxModeLi && eval(way.get("http://www.yugj881.com/resources/main/Lottery.yjf")) == 'http://www.yugj881.com/resources/main/0.001') {
				if (eval(way.get("http://www.yugj881.com/resources/main/Lottery.mode")) > Env.maxModeLi)
					way.set("http://www.yugj881.com/resources/main/Lottery.mode", Env.maxModeLi);
				moneySlider("slider-range", Env.minMode, Env.maxModeLi, way.get("http://www.yugj881.com/resources/main/Lottery.mode"), dragEqualizer);
			} else {
				moneySlider("slider-range", Env.minMode, Env.maxMode, way.get("http://www.yugj881.com/resources/main/Lottery.mode"), dragEqualizer);
			}
			curRule.calculatePrize(curRule.rulecode);
			curRule.vali();
			equalizer_poi(way.get("http://www.yugj881.com/resources/main/Lottery.mode"));
		} else if (/^[^\.]+\.times$/.test(selector)) {
			var times = way.get("Lottery.times");
			if (!times || times < 1) {
				way.set("Lottery.times", 1);
			}
			curRule.vali();
		} else if (/^[^\.]+\.mode$/.test(selector)) {
			if (curRule)
				curRule.calculatePrize(curRule.rulecode);
		} else if (/^[^\.]+\.context$/.test(selector)) {
			var group = selector.match(/^([^\.]+)\..+$/);
			curRule.vali();
		}
		/*
		 * else if(/^orderlist\.items\.[^\.]+\.times$/.test(selector)) { var
		 * group=selector.match(/^orderlist\.items\.([^\.]+)\..+$/);
		 * alert(way.get("orderlist.items."+group[1]+".times")); }
		 */
	}

	var iwac_checkbox = function(e) {
		if (e.target.checked) {
			if (!way.get("orderlist.iwac.item." + $(e.target).attr('id') + ".times") || !eval(way.get("orderlist.iwac.item." + $(e.target).attr('id') + ".times"))) {
				$('#times_' + $(e.target).attr('id')).val(1);
				way.set("orderlist.iwac.item." + $(e.target).attr('id') + ".times", 1);
			} else {
				$('#times_' + $(e.target).attr('id')).val(
					way.get("orderlist.iwac.item." + $(e.target).attr('id') + ".times"));
				way.set("orderlist.iwac.item." + $(e.target).attr('id') + ".times", way.get("orderlist.iwac.item." + $(e.target).attr('id') + ".times"));
			}

			if (!way.get("orderlist.iwac.exceptcount")) {
				way.set("orderlist.iwac.exceptcount", 1);
				$('#exceptcount').html("1");
			} else {
				way.set("orderlist.iwac.exceptcount", 1 + eval(way
					.get("orderlist.iwac.exceptcount")));
				$('#exceptcount').html(way.get("orderlist.iwac.exceptcount"));
			}

		} else {
			way.set("orderlist.iwac.exceptcount", way
				.get("orderlist.iwac.exceptcount") - 1);
			if (!way.get("orderlist.iwac.exceptcount")) {
				way.set("orderlist.iwac.exceptcount", "0");
				$('#exceptcount').html("0");
			} else
				$('#exceptcount').html(way.get("orderlist.iwac.exceptcount"));
			$('#times_' + $(e.target).attr('id')).val("0");
			way.set("orderlist.iwac.item." + $(e.target).attr('id') + ".times",
				"0");
			way.set("orderlist.iwac.item." + $(e.target).attr('id'), undefined);
		}
	}

	var iwac_times = function(e) {
		// var k = String.fromCharCode(e.which);
		var selector = $(e.target).attr('id');
		if (selector.indexOf("times_") >= 0) {
			selector = selector.substring(6, selector.length);
		}
		var k = $(e.target).val();
		if (isNaN(parseInt(k))) {
			way.set("orderlist.iwac.item." + selector + ".times", "0");
		} else {
			// var v = $(e.target).val() + k;
			way.set("orderlist.iwac.item." + selector + ".times", parseInt(k));
		}
	}

	var appencode_genTable = function(n) {

		$('#appendcode_table tr').remove();
		$.ajax({
			type: "post",
			url: "/ct-data/iwac",
			async: false,
			data: {
				showName: Env.lottery,
				except: way.get("showExpect.currExpect"),
				nu: n
			},
			datatype: "json",
			success: function(ms) {
				// console.log(ms);
				// way.set('iwac.table', ms);
				$.each(ms, function() {
					var uid = $.now() + "-" + Math.uuid(8);
					var newRow = '<tr><td width="10%"><input type="checkbox" id="' + uid + '_' + this.fullExpect + '"/></td>' + '<td width="28%">' + this.fullExpect + '</td>' + '<td width="15%"><input id="times_' + uid + '_' + this.fullExpect + '" class="bs" \
							type="text" /></td>' + '<td width="20px"><span id="total_' + uid + '_' + this.fullExpect + '">0</span></td>' + '<td width="27%">' + this.stopTime + '</td>' + '</tr>';
					$('#appendcode_table').append(newRow);
				});
				way.set('iwac.tablecount', ms.length);
				way.set('orderlist.iwac.exceptcount', '0');
				way.set("http://www.yugj881.com/resources/main/orderlist.iwac.item", null);
			}
		});
	}
	var appendCode_submit = function() {
		if (eval(way.get("useraccount.balance")) >= eval(way
				.get('orderlist.iwac.total'))) {
			$("#buyButton").removeAttr("onclick");
			var items = way.get("orderlist.items")

			// console.log(way.get("orderlist"));
			// $.each(items, function(key, val) {
			// 	if (val['bigCodes'])
			// 		val['bigCodes'] = key;
			// });
            $.each(items, function(key, val) {
                delete val.prize;
            });
			$.ajax({
				type: "post",
				url: "/ct-data/userBets/appendbuy",
				async: false,
				data: {
					orderlist: JSON.stringify(way.get("orderlist"))
				},
				datatype: "json",
				success: function(msg) {
					$("#buyButton").attr("onclick",
						"javascript:Lottery_Rule.pre_buy();");
					if (msg.sign) {
						closelayer();
						Lottery_Rule.list_clear();
						popTips(msg.message, 'succeed');
						dsFlushBalance();
					} else {
						popTips(msg.message, 'error');
					}
				},
				error: function() {
					$("#buyButton").attr("onclick", "javascript:Lottery_Rule.pre_buy();");
				}
			});
		} else {
			popTips("账户余额不足！！！", "waring");
		}

	}
	var list_appendCode = function() {
		if (!way.get("orderlist.total") || !eval(way.get("orderlist.total"))) {
			popTips('请先添加号码！', 'waring');
			return;
		}

		way.set("http://www.yugj881.com/resources/main/orderlist.iwac.item", null);
		way.set('orderlist.iwac.stopappend', ($('#iwac_stopappendcode').is(':checked')) ? 'yes' : 'no');
		way.set('orderlist.iwac.total', '0');
		way.set('iwac.maxtimes', 100);
		way.set('iwac.minprofit', 50);
		$("#orderlist_total").text("0");
		pop("extraNums");
		appencode_genTable(10);
	}

    var pre_buy = function () {
        //way.set("Lottery.maxPrize", Env.maxPrize);
        if (way.get("orderlist.ordercount") && way.get("orderlist.ordercount") > 0) {
            var maxPrize = 0;
            $("input.max-prize").each(function () {
                if (maxPrize < eval(this.value)) {
                    maxPrize = eval(this.value);
                }
            });
            // 弹窗不要400000 要 40万
            way.set("Lottery.maxPrize", "" + (maxPrize/10000));
            way.set("orderlist.currExpect", way.get("showExpect.currExpect"));
            pop("qrtouzhu");
        } else {
            popTips("请先添加号码", 'error');
        }
    };
	var pre_buyBtn = function() {
		$("#buyButton").removeAttr("onclick");
		closelayer();
		list_buy();
		//if(getCookie("currentContent") && getCookie("currentContent") == "yingkuimingxi"){
		//	setTimeout(function(){
		//		getUserBetsListProfitAndLossToday(Env.lottery);
		//	},2000);
		//} else if(getCookie("currentContent") && getCookie("currentContent") == "chaseNumberRecord"){
		//	setTimeout(function(){
		//		getUserBetsListChaseNumberToday(Env.lottery);
		//	},2000);
		//} else {
		//	setTimeout(function(){
		//		getUserBetsListToday(Env.lottery);
		//	},2000);
		//}
	}

	var list_buy = function() {
		if (eval(way.get("useraccount.balance")) >= eval(way
				.get('orderlist.total'))) {
			var items = way.get("orderlist.items")
				// $.each(items, function(key, val) {
				// 	if (val['bigCodes'])
				// 		val['bigCodes'] = key;
				// });
            $.each(items, function(key, val) {
                delete val.prize;
            });
			$.ajax({
				type: "post",
				url: "/ct-data/userBets/buy",
				data: {
					orderlist: JSON.stringify(way.get("orderlist"))
				},
				datatype: "json",
				success: function(msg) {
					$("#buyButton").attr("onclick", "javascript:Lottery_Rule.pre_buy();");
					if (msg.sign == true) {
						popTips(msg.message, "succeed");
						dsFlushBalance();
						// 设置默认模式kevin
						/*if (msg.defaultBetModel) {
							Env.defaultBetModel = parseInt(msg.defaultBetModel);
						}*/
						// end
						Lottery_Rule.list_clear();

					} else {
						if (msg.m_state == undefined) {
							popTips(msg.message, "error");
						}

					}
				},
				error: function() {
					$("#buyButton").attr("onclick", "javascript:Lottery_Rule.pre_buy();");
                    popTips('系统异常！', "error");
				}
			});
		} else {
			$("#buyButton").attr("onclick", "javascript:Lottery_Rule.pre_buy();");
			popTips('账户余额不足!', "error");
		}
	}
	var iwac_dialog_radio_click = function(e) {
		if (e.target.id == 'iwac_radio_lrl') {
			$('.titleB').find('span').hide();
			$('.titleB').find('span').eq(0).show();
			$('.titleB').find('span').eq(1).show();
			$('.titleB').find('span').eq(2).show();
		} else if (e.target.id == 'iwac_radio_tb') {
			$('.titleB').find('span').hide();
			$('.titleB').find('span').eq(0).show();
		} else if (e.target.id == 'iwac_radio_fb') {
			$('.titleB').find('span').hide();
			$('.titleB').find('span').eq(0).show();
			$('.titleB').find('span').eq(3).show();
			$('.titleB').find('span').eq(4).show();
			$('.titleB').find('span').eq(5).show();
		}
	}

	var iwac_stopappendc = function(e) {
		if (e.target.checked)
			way.set('orderlist.iwac.stopappend', 'yes');
		else
			way.set('orderlist.iwac.stopappend', 'no');
	}

	var iwac_except2_button_click = function(e) {
		if (way.dom('#iwacexceptcount').getValue())
			way.dom('#iwacexceptcount').setValue(
				way.dom('#iwacexceptcount').getValue().trim());
		if (!way.dom('#iwacexceptcount').getValue() || isNaN(way.dom('#iwacexceptcount').getValue()) || eval(way.dom('#iwacexceptcount').getValue()) < 1) {
			popTips('请添加正确的追号期数！', 'waring');
			return;
		}
		var iwac_starttimes = $("#iwac_starttimes").val();
		if (!iwac_starttimes || isNaN(iwac_starttimes) || eval(iwac_starttimes) < 1) {
			popTips('请添加正确的起始倍数！', 'waring');
			return;
		}
		if (way.dom('#iwacexceptcount').getValue() > 10) {
			// 总期数
			appencode_genTable(way.dom('#iwacexceptcount').getValue());
		} else {
			appencode_genTable(10);
		}
		if ($('.titleB').find('span').eq(1).css('display') == 'inline-block' && $('.titleB').find('span').eq(2).css('display') == 'inline-block') {
			if (!way.get('iwac.maxtimes') || isNaN(way.get('iwac.maxtimes')) || eval(way.get('iwac.maxtimes')) < 1) {
				popTips('请添加正确的最大倍投！', 'waring');
				return;
			}
			if (!way.get('iwac.minprofit') || isNaN(way.get('iwac.minprofit')) || eval(way.get('iwac.minprofit')) < 1) {
				popTips('请添加正确的最低利润率！', 'waring');
				return;
			}
			var hisl = 0;
			var fm = eval(way.get('iwac.prize')) - eval(way.get('http://www.yugj881.com/resources/main/iwac.cost')) - eval(way.get('http://www.yugj881.com/resources/main/iwac.cost')) * eval(way.get('iwac.minprofit')) / 100;
			$('#appendcode_table tr').each(function(index) {
						if (eval(way.dom('#iwacexceptcount').getValue()) <= index) {
							if ($(this).find('input[type="checkbox"]')
								.prop('checked'))
								$(this).find('input[type="checkbox"]')
								.trigger('click');
						} else {
							var t = Math.ceil(iwac_starttimes * hisl * (1 + eval(way.get('iwac.minprofit')) / 100) / fm);
                            var j = t;
                            if (!t || t <iwac_starttimes){
                                t = iwac_starttimes;
                            }
                            if (t > eval(way.get('iwac.maxtimes'))){
                                t = eval(way.get('iwac.maxtimes'));
                            }
                            way.set('orderlist.iwac.item.' + $(this).find('input[type="checkbox"]').attr('id') + '.times', t);
                            if (!$(this).find('input[type="checkbox"]').eq(0).prop('checked')) {
                                $(this).find('input[type="checkbox"]').eq(0).trigger('click');
                            }

                            hisl = hisl + eval(way.get('orderlist.iwac.item.' + $(this).find('input[type="checkbox"]').attr('id') + '.total'))*t;

                        }
					});
		} else if ($('.titleB').find('span').eq(3).css('display') == 'inline-block' && $('.titleB').find('span').eq(4).css('display') == 'inline-block' && $('.titleB').find('span').eq(5).css('display') == 'inline-block') {
			var iwac_parttimes = $("#iwac_parttimes").val();
			var iwac_partexcept = $("#iwac_partexcept").val();
			if (!iwac_parttimes || isNaN(iwac_parttimes) || eval(iwac_parttimes) < 1) {
				popTips('请添加正确的隔期倍数！', 'waring');
				return;
			}
			if (!iwac_partexcept || isNaN(iwac_partexcept) || eval(iwac_partexcept) < 1) {
				popTips('请添加正确的隔期！', 'waring');
				return;
			}
			var btimes = iwac_starttimes;
			$('#appendcode_table tr')
				.each(
					function(index) {
						if (eval(way.dom('#iwacexceptcount').getValue()) <= index) {
							if ($(this).find('input[type="checkbox"]')
								.prop('checked'))
								$(this).find('input[type="checkbox"]')
								.trigger('click');
						} else {
							if ($(this).find('input[type="checkbox"]')
								.prop('checked')) {
								if (way
									.get('orderlist.iwac.item.' + $(this)
										.find(
											'input[type="checkbox"]')
										.attr('id') + '.times') != btimes)
									way
									.set(
										'orderlist.iwac.item.' + $(this)
										.find(
											'input[type="checkbox"]')
										.attr(
											'id') + '.times',
										btimes);
							} else {
								way
									.set(
										'orderlist.iwac.item.' + $(this)
										.find(
											'input[type="checkbox"]')
										.attr(
											'id') + '.times',
										btimes);
								$(this).find('input[type="checkbox"]')
									.trigger('click');
							}
							if (index % eval(iwac_partexcept) == (eval(iwac_partexcept) - 1)) {
								btimes = btimes * eval(iwac_parttimes);
							}
						}
					});
		} else {
			$('#appendcode_table tr')
				.each(
					function(index) {
						if (eval(way.dom('#iwacexceptcount').getValue()) <= index) {
							if ($(this).find('input[type="checkbox"]')
								.prop('checked'))
								$(this).find('input[type="checkbox"]')
								.trigger('click');
						} else {
							if ($(this).find('input[type="checkbox"]')
								.prop('checked')) {
								if (way
									.get('orderlist.iwac.item.' + $(this)
										.find(
											'input[type="checkbox"]')
										.attr('id') + '.times') != iwac_starttimes)
									way
									.set(
										'orderlist.iwac.item.' + $(this)
										.find(
											'input[type="checkbox"]')
										.attr(
											'id') + '.times',
										iwac_starttimes);
							} else {
								way
									.set(
										'orderlist.iwac.item.' + $(this)
										.find(
											'input[type="checkbox"]')
										.attr(
											'id') + '.times',
										iwac_starttimes);
								$(this).find('input[type="checkbox"]')
									.trigger('click');
							}
						}
					});
		}

	}

	var movestring = function(a) {
		var h = "";
		var k = "01";
		var b = "";
		var f = "";
		var j = "";
		var g = false;
		var c = false;
		for (var e = 0; e < a.length; e++) {
			if (g == false) {
				h += a.substr(e, 1)
			}
			if (g == false && a.substr(e, 1) == "1") {
				c = true
			} else {
				if (g == false && c == true && a.substr(e, 1) == "0") {
					g = true
				} else {
					if (g == true) {
						b += a.substr(e, 1)
					}
				}
			}
		}
		h = h.substr(0, h.length - 2);
		for (var d = 0; d < h.length; d++) {
			if (h.substr(d, 1) == "1") {
				f += h.substr(d, 1)
			} else {
				if (h.substr(d, 1) == "0") {
					j += h.substr(d, 1)
				}
			}
		}
		h = f + j;
		return h + k + b
	}

	var getCombination = function(o, c) {
		var l = o.length;
		var r = new Array();
		var f = new Array();
		if (c > l) {
			return r
		}
		if (c == 1) {
			return o
		}
		if (l == c) {
			r[0] = o.join(",");
			return r
		}
		var a = "";
		var b = "";
		var s = "";
		for (var g = 0; g < c; g++) {
			a += "1";
			b += "1"
		}
		for (var e = 0; e < l - c; e++) {
			a += "0"
		}
		for (var d = 0; d < c; d++) {
			s += o[d] + ","
		}
		r[0] = s.substr(0, s.length - 1);
		var h = 1;
		s = "";
		while (a.substr(a.length - c, c) != b) {
			a = movestring(a);
			for (var d = 0; d < l; d++) {
				if (a.substr(d, 1) == "1") {
					s += o[d] + ","
				}
			}
			r[h] = s.substr(0, s.length - 1);
			s = "";
			h++;
		}
		return r;
	}

	// 一键投注
	var fastOrder = function () {
		if (way.get("Lottery.total") && way.get("Lottery.total") > 0) {
			if(addOrder()){
				pre_buy();  // 确认投注
			}
		} else {
			var times = way.get("Lottery.times");
			if (times < 1) {
				popTips('倍数不能小于1!', "error");
			} else {
				popTips('号码不完整，请重新选择!', "error");
			}
		}
	};
	return {
		chooseRule: chooseRule,
		init: init,
		addOrder: addOrder,
		delOrder: delOrder,
		list_clear: list_clear,
		list_appendCode: list_appendCode,
		appendCode_submit: appendCode_submit,
		pre_buy: pre_buy,
		pre_buyBtn: pre_buyBtn,
		verificateOrder: verificateOrder,
		iwac_checkbox: iwac_checkbox,
		iwac_times: iwac_times,
		dialogDetail: dialogDetail,
		getCombination: getCombination,
		udorder: udorder,
		fastOrder: fastOrder
	}
}();

/**
 * 根据shortName，获取彩种的相关期号与开奖时间
 * 
 * @param shortName
 */
var ClockEnv = {
	num: 5,
	numRange: '0-9'
}
var isFirstOpenTime = true;

function loadOpenTime(shortName) {
	$("p.lott-c-tips").hide();
	var ret = null;
	var retopen = null;
	$.ajax({
		type: "post",
		url: "/ct-data/loadOpenTime",
		data: {
			"shortName": shortName
		},
		datatype: "json",
		async: false,
		success: function(msg) {
			if (msg.sign ) {
				way.set("showExpect.lastExpect", msg.lastFullExpect);
				way.set("showExpect.currExpect", msg.currFullExpect);
                var openExpect = msg.lastExpect?parseInt(msg.lastExpect):0;
                var lotTipsHtml = '';
                if(STATIC_DATA.lottery_data[shortName].description[1]){
                    lotTipsHtml+="已开  &nbsp;<span>"+openExpect+"</span>&nbsp;   期&nbsp;  剩余  &nbsp;<span>"+(STATIC_DATA.lottery_data[shortName].description[1] - openExpect)+"</span>&nbsp;  期&nbsp;  总共  &nbsp;<span>"+STATIC_DATA.lottery_data[shortName].description[1]+"</span>&nbsp;  期"

                } else if(STATIC_DATA.lottery_data[shortName].description[0]){
                    lotTipsHtml+='开彩时间为:&nbsp;<font color="red">'+STATIC_DATA.lottery_data[shortName].description[0]+'</font>'
				}
				if(lotTipsHtml) {
					$("p.lott-c-tips").html(lotTipsHtml);
					$("p.lott-c-tips").show();
				} else {
					$("p.lott-c-tips").hide();
				}
				
				if (msg.remainTime&&eval(msg.remainTime) > 1) {
					if (!isFirstOpenTime) {
						$("#qihaotips").html($("#qihaotips").html()).show(300)
							.delay(30000).hide(300);
					}
					isFirstOpenTime = false;
					countdownTime(msg.remainTime, loadOpenTime, shortName);
					ret = msg.lastFullExpect;
					retopen = msg.openRemainTime;
				}else{
					if(msg.currFullExpect == "000000") {
						ret = msg.lastFullExpect;
					} else {
						setTimeout(function() {
							loadOpenTime(shortName);
						}, 1000);
					}
				}
			} else {
				popTips(msg.message, "error");
			}
		},
		error: function() {
			// 请求出错后5秒钟请求一次直到请求成功
			setTimeout(function() {
				loadOpenTime(shortName);
			}, 1000 * 5);
		}
	});
	if (ret) {
		// if (retopen && retopen > 0) {
		// 	setTimeout(function() {
		// 		lazyLoadOpenCode(shortName, ret);
		// 	}, 1000 * retopen);
		// } else {
			ckTimer = true;
			start();
			// loadOpenCode(shortName, ret);
            var lazyTime = getLotteryCodeLazyTime(retopen, shortName);

            setTimeout(function () {
                loadOpenCode(shortName, ret);
            }, lazyTime);
		// }
	}
}

/**
 * 各彩种抓取号码耗时
 *
 */
function getLotteryCodeLazyTime(retopen,shortname){
    var lazySecondTime = 2;

    switch (shortname) {
        case "ffc"      : lazySecondTime = 10; break;
        case "3fc"      : lazySecondTime = 30; break;
        case "5fc"      : lazySecondTime = 10; break;

        case "xyssc"    : lazySecondTime = 60; break;
        case "twxyssc"  : lazySecondTime = 60; break;
        case "jndbsxyssc" : lazySecondTime = 60; break;
        case "xdlxyssc" : lazySecondTime = 30; break;
        case "sgxyssc"  : lazySecondTime = 30; break;
        case "djxyssc"  : lazySecondTime = 30; break;

        case "hgxyssc"  : lazySecondTime = 30; break;
        case "hgxy3d"   : lazySecondTime = 30; break;
        case "xdlxy3d"  : lazySecondTime = 10; break;
        case "sgxy3d"   : lazySecondTime = 30; break;
        case "djxy3d"   : lazySecondTime = 30; break;
        case "xy3d"     : lazySecondTime = 80; break;
        case "twxy3d"   : lazySecondTime = 20; break;
        case "jndbsxy3d": lazySecondTime = 10; break;

        case "cqssc"    : lazySecondTime = 100; break;
        case "tjssc"    : lazySecondTime = 100; break;
        case "jxssc"    : lazySecondTime = 100; break;
        case "xjssc"    : lazySecondTime = 100; break;

        case "sd11x5"   : lazySecondTime = 120; break;
        case "gd11x5"   : lazySecondTime = 120; break;
        case "cq11x5"   : lazySecondTime = 120; break;
        case "ah11x5"   : lazySecondTime = 150; break;
        case "jx11x5"   : lazySecondTime = 150; break;
        case "sh11x5"   : lazySecondTime = 150; break;

        case "jsk3"     : lazySecondTime = 150; break;
        case "ahk3"     : lazySecondTime = 60; break;
        case "jlk3"     : lazySecondTime = 60; break;
        case "hbk3"     : lazySecondTime = 60; break;

        case "shssl"    : lazySecondTime = 60; break;
        case "cqkl10f"  : lazySecondTime = 60; break;
        case "gdkl10f"  : lazySecondTime = 60; break;
        case "fc3d"     : lazySecondTime = 60; break;
        case "pl3"      : lazySecondTime = 60; break;
        case "bjpk10"   : lazySecondTime = 60; break;
    }

    var lazyTime = eval(1000 * lazySecondTime) + eval(1000 * retopen);
    if (eval(lazyTime) < 0) {
        lazyTime = 1000;
    }

    return lazyTime;
}

function closedqihaotips() {
	$("#qihaotips").hide();
}

function lazyLoadOpenCode(shortName, expect) {
	$("#show_result").text('正在开奖中…');
	// $('.kjnr_shelter').removeClass('kjnr_shelter_dis');
	// $('.kjnr_shelter').addClass('kjnr_shelter_hid');
	if (!ckTimer) {
		ckTimer = true;
		start();
	}
	openCodeTimeOut = setTimeout(function() {
		loadOpenCode(shortName, expect)
	}, 1000 * 50);
}
/**
 * 根据shortName、expect获取相应的开奖号码
 * 
 * @param shortName
 * @param expect
 */
/**
 * 根据shortName、expect获取相应的开奖号码
 * 
 * @param shortName
 * @param expect
 */
var openCodeTimeOut = null;

function loadOpenCode(shortName, expect) {
	var ret = false;
	$.ajax({
		type: "post",
		url: "/ct-data/loadOpenCode",
		data: {
			"shortName": shortName,
			"expect": expect
		},
		datatype: "json",
		async: false,
		timeout: 5000,
		success: function(msg) {
			if (msg.sign == true) {
				if (msg.lastOpenCode.length > 0) {
					if (openCodeTimeOut) {
						clearInterval(openCodeTimeOut);
					}
					var lastExpect = way.get("showExpect.lastExpect");

					// 官方时时彩
					var isXyssc = false;
					if (msg.shortName.indexOf("xyssc") >= 0 && msg.sourceCode && msg.sourceCode.length > 0) {
						isXyssc = true;
					}
					// 官方3D
					var isXy3d = false;
					if (msg.shortName.indexOf("xy3d") >= 0 && msg.sourceCode && msg.sourceCode.length > 0) {
						isXy3d = true;
					}

					if (lastExpect == expect) {
						// 页面开奖号列表赋值
						var openCodeListVal = $(".ef-kj-lishi").find('dl').html();
						if (shortName == "azjn") {
							expect = expect.substr(12, expect.length);
						}

						// 官方时时彩
						if (isXyssc) {
							var sourceCodes = msg.sourceCode.split(",");
							var bigqiuTips = $("#qiuanimation5 > .qiubig");
							for (var i = 0; i < sourceCodes.length; i = i + 4) {
								/*var sum = (eval(sourceCodes[i])+eval(sourceCodes[i+1])+eval(sourceCodes[i+2])+eval(sourceCodes[i+3])).toString();
								var lastSumIndex = sum.length - 1;
								var sourceHtml = '<em>'+sourceCodes[i]+'</em>' +
									'+<em>'+sourceCodes[i+1]+'</em>' +
									'+<em>'+sourceCodes[i+2]+'</em>' +
									'+<em>'+sourceCodes[i+3]+'</em>' +
									'='+sum.substring(0, lastSumIndex)+'<span style="color:red;">'+sum.substring(lastSumIndex)+'</span>';
								
								bigqiuTips.eq(i/4).find(".span1").html(sourceHtml);*/
								bigqiuTips.eq(i / 4).find(".li_1").text(sourceCodes[i]);
								bigqiuTips.eq(i / 4).find(".li_2").text(sourceCodes[i + 1]);
								bigqiuTips.eq(i / 4).find(".li_3").text(sourceCodes[i + 2]);
								bigqiuTips.eq(i / 4).find(".li_4").text(sourceCodes[i + 3]);
							}
						}

						// 官方3D
						if (isXy3d) {
							var sourceCodes = msg.sourceCode.split(",");
							//var bigqiuTips = $("ul.lotter-bigqiu3 div.lotter-qiu3-tips");
							var bigqiuTips = $("#qiuanimation3 > .qiubig");
							for (var i = 0; i < 18; i = i + 6) {
								/*var sum = (eval(sourceCodes[i])+eval(sourceCodes[i+1])+eval(sourceCodes[i+2])+eval(sourceCodes[i+3])+eval(sourceCodes[i+4])+eval(sourceCodes[i+5])).toString();
								var sum = (eval(sourceCodes[i]) + eval(sourceCodes[i + 1]) + eval(sourceCodes[i + 2]) + eval(sourceCodes[i + 3]) + eval(sourceCodes[i + 4]) + eval(sourceCodes[i + 5])).toString();
								var lastSumIndex = sum.length - 1;
								var sourceHtml = '<ul>' +
									'<li class="s">' + sourceCodes[i] + '</li>' +
									'<li>+</li>' +
									'<li class="s">' + sourceCodes[i + 1] + '</li>' +
									'<li>+</li>' +
									'<li class="s">' + sourceCodes[i + 2] + '</li>' +
									'<li>+</li>' +
									'<li class="s">' + sourceCodes[i + 3] + '</li>' +
									'<li>+</li>' +
									'<li class="s">' + sourceCodes[i + 4] + '</li>' +
									'<li>+</li>' +
									'<li class="s">' + sourceCodes[i + 5] + '</li>' +
									'<li>=</li>' +
									'<li>' + sum.substring(0, lastSumIndex) + '<em class="dred">' + sum.substring(lastSumIndex) + '</em></li>' +
									'</ul>';
								bigqiuTips.eq(i/6).html(sourceHtml);*/
								bigqiuTips.eq(i / 6).find(".efli_1").text(sourceCodes[i]);
								bigqiuTips.eq(i / 6).find(".efli_2").text(sourceCodes[i + 1]);
								bigqiuTips.eq(i / 6).find(".efli_3").text(sourceCodes[i + 2]);
								bigqiuTips.eq(i / 6).find(".efli_4").text(sourceCodes[i + 3]);
								bigqiuTips.eq(i / 6).find(".efli_5").text(sourceCodes[i + 4]);
								bigqiuTips.eq(i / 6).find(".efli_6").text(sourceCodes[i + 5]);
							}
						}

						ckTimer = false;
						if (isXyssc || isXy3d) {
							stopLotteryBySourceCode(msg.lastOpenCode, msg.sourceCode);
						} else {
							stopLottery(msg.lastOpenCode);
						}

						if (openCodeListVal.indexOf(expect) < 0) {
							if(shortName === 'hgxyssc' || shortName === 'hgxy3d'){
								openCodeList(shortName);
							}  else {
								var openCode = msg.lastOpenCode;
								var html = '<dd';
								if (isXyssc) {
									html += ' class="kjq-qiu5-tips" ';
								}
								if (isXy3d) {
									html += ' class="kjq-qiu3-tips" ';
								}
								if(!isXyssc && !isXy3d){
									html += ' class="kjq-noqiu-tips"';
								}

								html += '><p>' + expect + '</p><div';
								if (msg.shortName && msg.shortName.indexOf("bjpk10") >= 0) {
									html += ' class="kjqiu-sty3"';
								} else if (msg.shortName && msg.shortName.indexOf("kl10f") >= 0) {
									html += ' class="kjqiu-sty2"';
								} else {
									html += ' class="kjqiu-sty1"';
								}
								html += '>';
								for (var j = 0; j < openCode.split(',').length; j++) {
									html += '<span>' + openCode.split(',')[j] + '</span>';
								}
								html += '</div>';
								if (isXyssc) {
									var s = msg.sourceCode.split(",");
									html += '<div class="qhxq">';
									for (var k = 0; k < s.length; k = k + 4) {
										var txt = eval(s[k]) + eval(s[k + 1]) + eval(s[k + 2]) + eval(s[k + 3]);
										txt = txt.toString();
										var head = txt.substring(0, txt.length - 1);
										var last = txt.substring(txt.length - 1);
										html += '<p><em>' + s[k] + '</em>+<em>' + s[k + 1] + '</em>+<em>' + s[k + 2] + '</em>+<em>';
										html += s[k + 3] + '</em>=' + head + '<em class="dred">' + last + '</em></p>';
									}
									html += '</div>';
								}
								if (isXy3d) {
									var s = msg.sourceCode.split(",");
									html += '<div class="qhxq">';
									for (var k = 0; k < 18; k = k + 6) {
										var txt = eval(s[k]) + eval(s[k + 1]) + eval(s[k + 2]) + eval(s[k + 3]) + eval(s[k + 4]) + eval(s[k + 5]);
										txt = txt.toString();
										var head = txt.substring(0, txt.length - 1);
										var last = txt.substring(txt.length - 1);
										html += '<p><em>' + s[k] + '</em>+<em>' + s[k + 1] + '</em>+<em>' + s[k + 2] + '</em>+<em>';
										html += s[k + 3] + '</em>+<em>' + s[k + 4] + '</em>+<em>';
										html += s[k + 5] + '</em>=' + head + '<em class="dred">' + last + '</em></p>';
									}
									html += '</div>';
								}
								html += '</dd>' + openCodeListVal;
								$(".ef-kj-lishi").find('dl')
									.html(html);
								$(".ef-kj-lishi").find('dl')
									.find('tr').eq(20).remove();
							}
						}
						openResult();
					}

					if (shortName.indexOf("xyssc") >= 0) {
						$("dd.kjq-qiu5-tips").find("div").eq(1).hide();
						$("dd.kjq-qiu5-tips").unbind();
						$("dd.kjq-qiu5-tips").hover(function() {
							// $(this).children("div").show();
							$(this).find("div").eq(1).show();
						}, function() {
							// $(this).children("div").hide();
							$(this).find("div").eq(1).hide();
						});
					}
					if (shortName.indexOf("xy3d") >= 0) {
						$("dd.kjq-qiu3-tips").find("div").eq(1).hide();
						$("dd.kjq-qiu3-tips").unbind();
						$("dd.kjq-qiu3-tips").hover(function() {
							// $(this).children("div").show();
							$(this).find("div").eq(1).show();
						}, function() {
							// $(this).children("div").hide();
							$(this).find("div").eq(1).hide();
						});
					}

					if (isXyssc) {
						$("#qiuanimation5 > .qiubig > .jgtip").hide();
						$("#qiuanimation5 > .qiubig > .bigone").unbind();
						$("#qiuanimation5 > .qiubig > .bigone").hover(function() {
							$(this).parent().find(".jgtip").show();
						}, function() {
							$(this).parent().find(".jgtip").hide();
						});
					}
					if (isXy3d) {
						$("#qiuanimation3 > .qiubig > .jgtip").hide();
						$("#qiuanimation3 > .qiubig > .bigone").unbind();
						$("#qiuanimation3 > .qiubig > .bigone").hover(function() {
							$(this).parent().find(".jgtip").show();
						}, function() {
							$(this).parent().find(".jgtip").hide();
						});
					}
				} else {
					if (shortName.indexOf("xyssc") >= 0) {
						$("#qiuanimation5 > .qiubig > .jgtip").hide();
						$("#qiuanimation5 > .qiubig > .bigone").unbind();
					}
					if (shortName.indexOf("xy3d") >= 0) {
						$("#qiuanimation3 > .qiubig > .jgtip").hide();
						$("#qiuanimation3 > .qiubig > .bigone").unbind();
					}
					ret = true;
				}
				if (isXy3d) {
					$(".lotter-bigqiu3").show();
					$(".lotter-bigqiu3").siblings().hide();
					if(msg.lastOpenCode){
						way.set("showExpect.openCode1", msg.lastOpenCode.split(',')[0]);
						way.set("showExpect.openCode2", msg.lastOpenCode.split(',')[1]);
						way.set("showExpect.openCode3", msg.lastOpenCode.split(',')[2]);
					}

				}
				if (isXyssc) {
					$(".lotter-bigqiu5").show();
					$(".lotter-bigqiu5").siblings().hide();
					if(msg.lastOpenCode){
						way.set("showExpect.openCode1", msg.lastOpenCode.split(',')[0]);
						way.set("showExpect.openCode2", msg.lastOpenCode.split(',')[1]);
						way.set("showExpect.openCode3", msg.lastOpenCode.split(',')[2]);
						way.set("showExpect.openCode4", msg.lastOpenCode.split(',')[3]);
						way.set("showExpect.openCode5", msg.lastOpenCode.split(',')[4]);
					}

				}
			} else {
				if (shortName.indexOf("xyssc") >= 0) {
					$("#qiuanimation5 > .qiubig > .jgtip").hide();
					$("#qiuanimation5 > .qiubig > .bigone").unbind();
				}
				if (shortName.indexOf("xy3d") >= 0) {
					$("#qiuanimation3 > .qiubig > .jgtip").hide();
					$("#qiuanimation3 > .qiubig > .bigone").unbind();
				}
				popTips(msg.message, 'error');
			}
		},
		error: function() {
			// 请求出错后5秒钟请求一次直到请求成功
			setTimeout(function() {
				loadOpenCode(shortName, expect);
			}, 1000 * 5);
		}
	});
	if (ret) {
		var lastExpect = way.get("showExpect.lastExpect");
		if (lastExpect == expect) {
			if (openCodeTimeOut) {
				clearInterval(openCodeTimeOut);
			}
			openCodeTimeOut = setInterval(function() {
				loadOpenCode(shortName, expect);
			}, 5 * 1000);
		}
	}
}

var openCodeList = function(shortName) {
	var num = 20;
	if (ClockEnv.num == 10) {
		num = 7;
	}
	$.ajax({
		type: "post",
		url: "/ct-data/openCodeList",
		data: {
			"shortName": shortName,
			"num": num
		},
		datatype: "json",
		success: function(msg) {
			if (msg.sign == true) {
				$(".ef-kj-lishi").find('dl').empty();
				var openCodeList = msg.openCodeList;
				for (var i = 0; i < openCodeList.length; i++) {
					var expect = openCodeList[i].expect;
					var openCode = openCodeList[i].openCode;
					if (openCode) {
						// 官方时时彩
						var isXyssc = false;
						if (shortName.indexOf("xyssc") >= 0 && openCodeList[i].remarks && openCodeList[i].remarks.length > 0) {
							isXyssc = true;
						}
						var isXy3d = false;
						if (shortName.indexOf("xy3d") >= 0 && openCodeList[i].remarks && openCodeList[i].remarks.length > 0) {
							isXy3d = true;
						}

						var html = '<dd';
						if (isXyssc) {
							html += ' class="kjq-qiu5-tips"';
						}
						if (isXy3d) {
							html += ' class="kjq-qiu3-tips"';
						}
						if(!isXyssc && !isXy3d){
							html += ' class="kjq-noqiu-tips"';
						}

						var openCodes = openCode.split(',');

					/*	if (openCodes.length <= 5)
							html += '<div class="kjqiu-sty1';
						if (openCodes.length == 8)
							html += '<div class="kjqiu-sty2';
						if (openCodes.length == 10)
							html += '<div class="kjqiu-sty3';
						if (isXyssc) {
							html += ' kjq-qiu5-tips';
						}
						if (isXy3d) {
							html += ' kjq-qiu3-tips';
						}*/

						html += '" ><p>' + expect + '</p><div';
						/*if (msg.shortName && msg.shortName.indexOf("bjpk10") >= 0) {
							html += ' class="kjqiu-sty3"';
						} else if (msg.shortName && msg.shortName.indexOf("kl10f") >= 0) {
							html += ' class="kjqiu-sty2"';
						} else {
							html += ' class="kjqiu-sty1"';
						}*/


						if (openCodes.length <= 5) {
							html += ' class="kjqiu-sty1"';
						} else if (openCodes.length == 8) {
							html += ' class="kjqiu-sty2"';
						} else if (openCodes.length == 10){
							html += ' class="kjqiu-sty3"';
						}
						if (isXyssc) {
							html += ' kjq-qiu5-tips';
						}
						if (isXy3d) {
							html += ' kjq-qiu3-tips';
						}
						/*if (openCodes.length <= 5)
							html += '<div class="kjqiu-sty1';
						if (openCodes.length == 8)
							html += '<div class="kjqiu-sty2';
						if (openCodes.length == 10)
							html += '<div class="kjqiu-sty3';*/
						/*if (isXyssc) {
							html += ' kjq-qiu5-tips';
						}
						if (isXy3d) {
							html += ' kjq-qiu3-tips';
						}*/
						html += '>';
						for (var j = 0; j < openCodes.length; j++) {
							html += '<span>' + openCodes[j] + '</span>';
						}
						html += '</div>';
						if (isXyssc) {
							var s = openCodeList[i].remarks.split(",");
							html += '<div class="qhxq">';
							for (var k = 0; k < s.length; k = k + 4) {
								var txt = eval(s[k]) + eval(s[k + 1]) + eval(s[k + 2]) + eval(s[k + 3]);
								txt = txt.toString();
								var head = txt.substring(0, txt.length - 1);
								var last = txt.substring(txt.length - 1);
								html += '<p><em>' + s[k] + '</em>+<em>' + s[k + 1] + '</em>+<em>' + s[k + 2] + '</em>+<em>';
								html += s[k + 3] + '</em>=' + head + '<em class="dred">' + last + '</em></p>';
							}
							html += '</div>';
						}
						if (isXy3d) {
							var s = openCodeList[i].remarks.split(",");
							html += '<div class="qhxq">';
							for (var k = 0; k < 18; k = k + 6) {
								var txt = eval(s[k]) + eval(s[k + 1]) + eval(s[k + 2]) + eval(s[k + 3]) + eval(s[k + 4]) + eval(s[k + 5]);
								txt = txt.toString();
								var head = txt.substring(0, txt.length - 1);
								var last = txt.substring(txt.length - 1);
								html += '<p><em>' + s[k] + '</em>+<em>' + s[k + 1] + '</em>+<em>' + s[k + 2] + '</em>+<em>';
								html += s[k + 3] + '</em>+<em>' + s[k + 4] + '</em>+<em>';
								html += s[k + 5] + '</em>=' + head + '<em class="dred">' + last + '</em></p>';
							}
							html += '</div>';
						}
						html += '</dd>'
						$(".ef-kj-lishi").find('dl').append(html);
					}
				}

				if (shortName.indexOf("xyssc") >= 0) {
					$("dd.kjq-qiu5-tips").unbind();
					$("dd.kjq-qiu5-tips").hover(function() {
						// $(this).children("div").show();
						$(this).find("div").eq(1).show();
					}, function() {
						// $(this).children("div").hide();
						$(this).find("div").eq(1).hide();
					});
				}
				if (shortName.indexOf("xy3d") >= 0) {
					$("dd.kjq-qiu3-tips").unbind();
					$("dd.kjq-qiu3-tips").hover(function() {
						$(this).find("div").eq(1).show();
					}, function() {
						$(this).find("div").eq(1).hide();
					});
				}
			} else {
				popTips(msg.message, "error");
			}
		}
	});
}

/**
 * 摇奖计时器
 */
var ckTimer; // 摇奖计时器
function start() {

	var n_numRangeArray = ClockEnv.numRange.split("-");

	if (ckTimer) {
		openLottery(ClockEnv.num, n_numRangeArray[1]);
	}
}

var dingdan = function(id) {

}

$(function() {
	$('.lott-Control').on('click', '.l-c-one li', function(e) {
		e.preventDefault();
		$(this).addClass('cur').siblings().removeClass('cur');
	});
	$('.lott-Control').on('click', '.l-c-item li', function(e) {
		e.preventDefault();
		$('http://www.yugj881.com/resources/main/.l-c-item .cur').removeClass('cur');
		$(this).addClass('cur');
	});
	var searchStr = window.location.search;
	var lotteryCode = getQueryString(searchStr.substr(1), "code");
	if (!lotteryCode) {
		lotteryCode = 'cqssc';
	}
	Lottery_Rule.init(lotteryCode);
    isShowGW(lotteryCode)

	/*var codes = ["xyssc","hgxyssc","xy3d","twxy3d","hgxy3d","twxyssc","cqssc","tjssc","jxssc","xjssc","sd11x5","gd11x5","ah11x5","jx11x5","sh11x5","cqkl10f","gdkl10f","jsk3","ahk3","jlk3","hbk3","fc3d","pl3","bjpk10"];
	setInterval(function(){
		Lottery_Rule.init(codes[Math.floor(Math.random()*codes.length)]);
	}, 3000);*/

	$("span.efmin").on("click", function() {
		var curTimes = eval(way.get('Lottery.times'));
		if (curTimes > 1) {
			way.set('Lottery.times', --curTimes);
		}
	});
	$("span.efadd").on("click", function() {
		var curTimes = eval(way.get('Lottery.times'));
		if (curTimes < 99999) {
			way.set('Lottery.times', ++curTimes);
		}
	});
});

function isShowGW(code) {
    $.each(LOTTERYLIST_DATA, function (key, val) {
        $.each(val, function (ckey, cval) {
            if(cval && cval.state>0) {
                if(cval.shortName == code){
                    if(cval.officialUrl){
                        $(".lottery_guanfang a").attr('href',cval.officialUrl)
                        $(".lottery_guanfang").show()
                    } else {
                        $(".lottery_guanfang a").attr('href','javascript:;')
                        $(".lottery_guanfang").hide();
                    }
                }
            }
        });
    });
}

//异步去取上一次的开奖结果和中奖情况
function openResult() {
	var expect = way.get("showExpect.lastExpect");
	var shortName = Env.lottery;
	$.ajax({
		type: "post",
		url: "/ct-data/userBets/openResult",
		data: {
			"shortName": shortName,
			"expect": expect
		},
		datatype: "json",
		success: function(msg) {
			if (msg.sign) {
				if (msg.isOpen) {
					if (msg.money[0].prizeMoney > 0) {
						$(".touzhuzj ul").empty();
						var insertHtml = "<li>投注彩种：<span>" + msg.showName + "</span></li>";
						insertHtml += "<li>投注期号：<span>" + msg.expect + "</span></li>";
                        insertHtml += "<li>投注金额：<span>" + msg.money[0].totalMoney + "元</span></li>";
                        insertHtml += "<li>中奖金额：<span>" + msg.money[0].prizeMoney + "元</span></li>";
                        insertHtml += "<li>本次盈亏：<span>" + (eval(msg.money[0].prizeMoney) - eval(msg.money[0].totalMoney)).toFixed(4) + "元</span></li>";
						$(".touzhuzj ul").html(insertHtml);
						// pop('kjts','320px','250px');
						$(".touzhuzj").html($(".touzhuzj").html()).show(300).delay(30000).hide(300);
						audioPlay(1);
						// $("#kjts").html().show(300).delay(3000).hide(300);
					}
					//if(getCookie("currentContent") && getCookie("currentContent") == "yingkuimingxi"){
					//	setTimeout(function(){
					//		getUserBetsListProfitAndLossToday(Env.lottery);
					//	},2000);
					//} else if(getCookie("currentContent") && getCookie("currentContent") == "chaseNumberRecord"){
					//	setTimeout(function(){
					//		getUserBetsListChaseNumberToday(Env.lottery);
					//	},2000);
					//} else {
					//	setTimeout(function(){
					//		getUserBetsListToday(Env.lottery);
					//	},2000);
					//}
				} else {
					setTimeout(function() {
						openResult();
					}, 5 * 1000);
				}
			} else {
				popTips(msg.message, "error");
			}
		}
	});
}

/**
 * 当天投注记录
 * @param shortName
 */
function getUserBetsListToday(shortName) {
	if (!shortName) {
		shortName = Env.lottery;
	}
	$("#userBetsListToday").empty();
	$.ajax({
		url: "/ct-data/userBets/userBetsListToday",
		type: "post",
		dataType: "json",
		data: {
			"shortName": shortName
		},
		success: function (data) {
			if (data.sign === true) {
				var html = "";
				$.each(data.userbetList, function (idx, val) {
					html += '<tr>';
					html += '<td onclick="getBillInfo(\''+val.billno+'\')">'+val.billno + '</td>';
					html += '<td>' + val.betsTimes + '</td>';
					html += '<td>' + val.ruleName + '</td>';
					html += '<td>' + val.expect + '</td>';
					html += '<td>' + val.betsMoney + '</td>';
					html += '<td>' +( val.prizeMoney? val.prizeMoney :0)+ '</td>';
					html += '<td'
					if(val.state == '未中奖'){
						html += ' class="sty-yzj"';
					}else if(val.state == '已中奖'){
						html += ' class="sty-ycd"';
					}
					html += '>' + val.state + '</td>';
					html += '</tr>';
				});
				$("#userBetsListToday").html(html);
			}
		},
		error: function (XMLHttpRequest, textStatus, errorThrown) {
		}
	});
}

/**
 * 当天投注盈亏
 * @param shortName
 */
function getUserBetsListProfitAndLossToday(shortName) {
	if(!shortName) {
		shortName = Env.lottery;
	}
	setCookie("currentContent", "yingkuimingxi", 1);
	$("#userBetsListToday").empty();
	$.ajax({
		url : "/ct-data/userBets/userBetsListProfitAndLossToday",
		type : "post",
		dataType : "json",
		data : {
			"shortName" : shortName
		},
		success : function(data) {
			if(data.sign === true) {
				var html = "";
				$.each(data.userbetList, function(idx, val){
					html += '<tr>';
					html += '<td onclick="getBillInfo(\''+val.billno+'\')">'+val.billno + '</td>';
					html += '<td>' + val.betsTimes + '</td>';
					html += '<td>' + val.ruleName + '</td>';
					html += '<td>' + val.expect + '</td>';
					html += '<td>' + val.betsMoney + '</td>';
					html += '<td>' +( val.prizeMoney? val.prizeMoney :0)+ '</td>';
					html += '<td';
					if("未中奖" === val.state) {
						//html += ' class="red"';
						html += ' class="sty-yzj"';
					}else if("已中奖" === val.state) {
						html += ' class="sty-ycd"';
					}
					html += '>' + val.state + '</td>';
					html += '</tr>';
				});
				$("#userBetsListToday").html(html);
			}
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
		}
	});
}

/**
 * 当天追号记录
 */
function getUserBetsListChaseNumberToday(shortName) {
	if (!shortName) {
		shortName = Env.lottery;
	}
	setCookie("currentContent", "chaseNumberRecord", 1);
	$("#userBetsListToday").empty();
	$.ajax({
		url: "/ct-data/userBets/userBetsListAppToday",
		type: "post",
		dataType: "json",
		data: {
			"shortName": shortName
		},
		success: function (data) {
			if (data.sign === true) {
				var html = "";
				var prizeMoney = 0;
				$.each(data.page.root, function (idx, val) {
					prizeMoney = val.prizeMoney;
					html += '<tr>';
					html += '<td onclick="getBillInfo(\''+val.billno+'\')">'+val.billno + '</td>';
					html += '<td>' + val.betsTimes + '</td>';
					html += '<td>' + val.ruleName + '</td>';
					html += '<td>' + val.expect + '</td>';
					html += '<td>' + val.betsMoney + '</td>';
					if(prizeMoney){
						html += '<td>' + prizeMoney + '</td>';
					} else {
						html += '<td>0</td>';
					}

					html += '<td';
					if(2 == val.state) {
						html += ' class="sty-yzj"';
					}else if(3 == val.state) {
						html += ' class="sty-ycd"';
					}
					html += '>';
					switch(val.state){
						case 1 : html += '未开奖'; break;
						case 2 : html += '未中奖'; break;
						case 3 : html += '已中奖'; break;
						default: html += '已撤单'; break;
					}
					html += '</td>';
					html += '</tr>';
				});
				$("#userBetsListToday").html(html);
			}
		},
		error: function (XMLHttpRequest, textStatus, errorThrown) {
		}
	});
}